package com.example.servlet;

import com.example.dao.NovelDao;
import com.example.dao.UserDao;
import com.example.domain.Novel;
import com.example.domain.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;
@WebServlet("/AdminNovelHelpServlet")
public class AdminNovelHelpServlet extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    {
        request.setCharacterEncoding("utf-8");
        HttpSession session=request.getSession();
        String novel_id=request.getParameter("novel_id");
        NovelDao novelDao=new NovelDao();
        Novel novel=novelDao.getNovelById(Integer.parseInt(novel_id));

        if (novel!=null){
            session.setAttribute("novel",novel);
            request.getRequestDispatcher("admin_NovelUpdate.jsp").forward(request,response);
        }
        else{
            request.setAttribute("msg","小说不存在");
            request.getRequestDispatcher("admin_Novel.jsp").forward(request,response);
        }
    }
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    {
        this.doGet(request,response);
    }
}
